function check_reg_form() {
	reg_form = document.forms["registration_form"];

	if( reg_form == null ) {
		return false;
	}else{
		var alphanumeric = /^([a-zA-Z0-9_-]+)$/;
		
		var uname = reg_form.username;
		var pwd1 = reg_form.password1;
		var pwd2 = reg_form.password2;
		var sq = reg_form.secret_question;
		var sa = reg_form.secret_answer;
		
		if( (uname == null) || (pwd1 == null) || (pwd2 == null)
			|| (sq == null)  || (sa == null) ) {
			return false;
		}else{
			if( uname.value.length < 6 ) {
				alert("Username must contain at least 6 characters.");
				return false;
			}
			if( !alphanumeric.test(username.value) ) {
				alert("Username can only contain alphanumeric characters (a-Z,0-9,_,-).");
				return false;
			}
			
			if( pwd1.value.length < 6 ) {
				alert("Password must contain at least 6 characters.");
				return false;
			}
			if( pwd2.value.length < 6 ) {
				alert("Password confirmation must contain at least 6 characters.");
				return false;
			}
			if( pwd1.value != pwd2.value ) {
				alert("Please confirm your password correctly.");
				return false;
			}
			if( (!alphanumeric.test(pwd1.value)) || (!alphanumeric.test(pwd2.value)) ) {
				alert("Password can only contain alphanumeric characters (a-Z,0-9,_,-).");
				return false;
			}
			
			if( sq.value.length < 6 ) {
				alert("Secret question must contain at least 6 characters.");
				return false;
			}
			if( !alphanumeric.test(sq.value) ) {
				alert("Secret question can only contain alphanumeric characters (a-Z,0-9,_,-).");
				return false;
			}
			if( sa.value.length < 6 ) {
				alert("Secret answer must contain at least 6 characters.");
				return false;
			}
			if( !alphanumeric.test(sa.value) ) {
				alert("Answer of secret question can only contain alphanumeric characters (a-Z,0-9,_,-).");
				return false;
			}
			
			return true;
		}
	}
}